import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;


public class Gene {
	private String _name;
	private int _csIndex;
	private HashSet<String> _annotations;
	private LinkedList<Cluster> _clusters; // TEMP TODO consider making a set
	
	public Gene(String name) {
		this(name, -1);
	}
	
	public Gene(String name, int csIndex) {
		_name         = name;
		_csIndex      = csIndex;
		_annotations = new HashSet<String>();
		_clusters      = new LinkedList<Cluster>();
	}
	
	public String getName() {
		return _name;
	}

	public int getCSIndex() {
		return _csIndex;
	}
	
	public void setCSIndex(int idx) {
		_csIndex = idx;
	}
	
	/** Annotations related methods **/
	public Iterator<String> annotationsIterator() {
		return _annotations.iterator();
	}

	public Boolean isAnnotated() {
		return _annotations.size() != 0;
	}	
	
	public Boolean addAnnotation(String annot) {
		return _annotations.add(annot);
	}
	
	public Boolean hasAnnotation(String annotation, AnnotationsManager annotMgr) {
		return annotMgr.isGeneAnnotated(this, annotation);
	}
	
	/** Clusters related methods **/	
	public Iterator<Cluster> clustersIterator() {
		return _clusters.iterator();
	}
	
	public int clustersCount() {
		return _clusters.size();
	}
	
	/**
	 * Adds cluster to node's cluster list.
	 * USE ONLY THROUGH ClusteringAlgorithms!
	 * @param clust cluster to remove from clusters list.
	 */
	public void addCluster(Cluster clust) {
		_clusters.add(clust);
	}
	
	/**
	 * Removes cluster from node's cluster list.
	 * USE ONLY THROUGH ClusteringAlgorithms!
	 * @param clust cluster to remove from clusters list.
	 */
	public void removeCluster(Cluster clust) {
		_clusters.remove(clust); // TEMP TODO make sure this works.
	}
	
}
